﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Security.Principal;
using System.Xml.Linq;
using COM.Data;

namespace SampleApp.Data
{
    /// <summary>
    /// 所有用户
    /// </summary>
    public class AppEveryOne : PermissionRole
    {
        public override string EnumRoleName
        {
            get
            {
                return EnumAppRoleName.AppEveryOne;
            }
        }

        public AppEveryOne(string userCode)
        {
            this.UserCode = userCode;
        }

        public string UserCode { get; private set; }
        public AppEveryOne() { }

        public override XElement RoleDataXml
        {
            get
            {
                return new XElement("r",
                                    new XAttribute("UserCode", this.UserCode),
                                    EnumRoleName
                                    );
            }
        }

        public override void ParseXml(XElement x)
        {
            this.UserCode = x.Attribute("UserCode").Value;
        }
    }

    public class AppEmployee : AppEveryOne
    {
        public override string EnumRoleName
        {
            get
            {
                return EnumAppRoleName.AppEmployee;
            }
        }

        public AppEmployee(string userCode, string deptCode)
            :base(userCode)
        {
            this.DeptCode = deptCode;
        }

        public string DeptCode { get; protected set; }

        public AppEmployee() { }

        public override XElement RoleDataXml
        {
            get
            {
                return new XElement("r",
                                    new XAttribute("UserCode", this.UserCode),
                                    new XAttribute("DeptCode", this.DeptCode),
                                    this.EnumRoleName
                                    );
            }
        }

        public override void ParseXml(XElement x)
        {
            base.ParseXml(x);
            this.DeptCode = (string)x.Attribute("DeptCode");
        }
    }

    /// <summary>
    /// 通用用户角色定义,没有扩展鉴权参数
    /// </summary>
    public class AppAdmin : AppEveryOne
    {
        public override string EnumRoleName
        {
            get
            {
                return EnumAppRoleName.AppAdmin;
            }
        }

        public AppAdmin(string userCode)
            : base(userCode)
        {
        }

        public AppAdmin() { }
    }

    /// <summary>
    /// 通用用户角色定义,没有扩展鉴权参数
    /// </summary>
    public class AppTest : AppEmployee
    {
        public override string EnumRoleName
        {
            get
            {
                return EnumAppRoleName.AppTest;
            }
        }

        public AppTest(string userCode, string deptCode)
            : base(userCode, deptCode)
        {
        }

        public AppTest() { }

    }


    public class AppDev : AppEveryOne
    {
        public override string EnumRoleName
        {
            get
            {
                return EnumAppRoleName.AppDev;
            }
        }

        public AppDev(string userCode)
            : base(userCode)
        {
        }

        public AppDev() { }
    }


    public class AppDeptLeader : AppEmployee
    {
        public override string EnumRoleName
        {
            get
            {
                return EnumAppRoleName.AppDeptLeader;
            }
        }

        public AppDeptLeader(string userCode, string deptCode)
            : base(userCode, deptCode)
        {
        }

        public AppDeptLeader() { }

    }

    public class AppCompLeader : AppEveryOne
    {
        public override string EnumRoleName
        {
            get
            {
                return EnumAppRoleName.AppCompLeader;
            }
        }

        public AppCompLeader(string userCode)
            : base(userCode)
        {
        }

        public AppCompLeader() { }

    }
}


